﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Control_UpdateTravelPlanControl : System.Web.UI.UserControl
{
    string id = null;
    string getSLocation = null;
    string getELocation = null;
    string getdate = null;
    string gettime = null;
    private string stime = null;
    private string etime = null;
    ListAndProcessData ws = new ListAndProcessData();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            id = Request.QueryString["idlo"].ToString();
            getSLocation = Request.QueryString["startLo"].ToString();
            getELocation = Request.QueryString["Endlo"].ToString();
            getdate = Request.QueryString["date"].ToString();
            gettime = Request.QueryString["time"].ToString();
            txtSlocation.Text = getSLocation;
            txtELocation.Text = getELocation;
            txtstartdate.Text = getdate;
       
            DropDownList1.SelectedValue =  gettime.Substring(0, 2);
            DropDownList2.SelectedValue = gettime.Substring(3, 2);
            DropDownList3.SelectedValue = gettime.Substring(8, 2);
            DropDownList4.SelectedValue = gettime.Substring(11, 2);
        }
        
        
    }
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        if ((DropDownList2.SelectedItem).ToString().Equals("") && (DropDownList4.SelectedItem).ToString().Equals(""))
        {
             stime = (DropDownList1.SelectedItem).ToString() + ":00";
             etime = (DropDownList3.SelectedItem).ToString() + ":00";
        }
        else
        {
             stime = (DropDownList1.SelectedItem).ToString() + ":" + (DropDownList2.SelectedItem).ToString();
             etime = (DropDownList3.SelectedItem).ToString() + ":" + (DropDownList4.SelectedItem).ToString();
        }
        bool a = false;
        a = ws.UpdateTravelPlan(id, txtSlocation.Text, txtELocation.Text, txtstartdate.Text,stime + " > " + etime);
        if (a == true)
        {
            Response.Redirect("../Admin/ShowTravelPlan_Admin.aspx");

        }
        else
        {
            Response.Redirect("Default3.aspx");
        }
    }
    protected void btnreset_Click(object sender, EventArgs e)
    {

    }
}